﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using Modules.Catalog.Core.Commands.Register;
using Modules.Catalog.Core.Queries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Modules.Catalog.Controllers
{
    [ApiController]
    [Route("/api/catalog/[controller]")]
    internal class BrandsController : ControllerBase
    {
        private readonly IMediator mediator;

        public BrandsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        [HttpGet]
        public async Task<IActionResult> GetAll()
        {
            var brands = await mediator.Send(new GetAllBrandsQuery());
            return Ok(brands);
        }
        [HttpPost]
        public async Task<IActionResult> RegisterBrand(RegisterBrandCommand command)
        {
            return Ok(await mediator.Send(command));
        }
    }
}
